﻿using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;

namespace ConsoleApp2
{
    public class RedisConnect
    {
        private string _ip { get; set; }
        private int _port { get; set; }
        public Socket clientChannel { get; set; }
        public RedisConnect(string ip, int port)
        {
            _ip = ip;
            _port = port;
            clientChannel = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            clientChannel.Connect(_ip,_port);
            
        }

        public void WritePing()
        {
            string str = "*1\r\n$4\r\nPING\r\n";
            byte[] bytes = Encoding.UTF8.GetBytes(str);
            clientChannel.Send(bytes);
            byte[] reslut = new byte[100];
            clientChannel.Receive(reslut);
            string st = Encoding.UTF8.GetString(reslut);
            Console.WriteLine(st);
        }
    }
}
